<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" >
<head>
    <th:block th:include="include :: header('修改产品系列')" />
</head>
<body class="white-bg">
<div class="wrapper wrapper-content animated fadeInRight ibox-content">
    <form class="form-horizontal m" id="form-series-edit" th:object="${series}">
        <input id="seriesId" name="seriesId" type="hidden" th:field="*{seriesId}"/>
        <div class="form-group">
            <label class="col-sm-3 control-label">系列名称：</label>
            <div class="col-sm-8">
                <input class="form-control" type="text" name="typeName" id="typeName" th:field="*{seriesName}" required>
            </div>
        </div>
        <div class="form-group">
            <label class="col-sm-3 control-label">系列描述：</label>
            <div class="col-sm-8">
                <textarea id="seriesDesc" name="seriesDesc" class="form-control">[[*{seriesDesc}]]</textarea>
            </div>
        </div>
    </form>
</div>
<th:block th:include="include :: footer" />
<script type="text/javascript">
    var prefix = ctx + "product/series";

    $("#form-series-edit").validate({
        onkeyup: false,
        rules:{
            typeName:{
                remote: {
                    url: prefix + "/checkSeriesNameUnique",
                    type: "post",
                    dataType: "json",
                    data: {
                        "seriesId" : function () {
                            return $.common.trim($("#seriesId").val())
                        },
                        "seriesDesc" : function() {
                            return $.common.trim($("#seriesDesc").val());
                        }
                    },
                    dataFilter: function(data, type) {
                        return $.validate.unique(data);
                    }
                }
            },
            typeSort:{
                digits:true
            },
        },
        messages: {
            "seriesName": {
                remote: "产品系列名称已经存在"
            }
        },
        focusCleanup: true
    });

    function submitHandler() {
        if ($.validate.form()) {
            $.operate.save(prefix + "/edit", $('#form-series-edit').serialize());
        }
    }
</script>
</body>
</html>
